<html> 
	<head>
	<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
	<script language="javascript">
	window.onload=function()
	{
		optionYear=document.p.year.outerHTML;
		optionMonth=document.p.month.outerHTML
		optionDay=document.p.day.outerHTML
		month=[31,28,31,30,31,30,31,31,30,31,30,31]
		
		var y=new Date().getFullYear()
		var YYYY=optionYear.substring(0,optionYear.length-9)
		for(var i=y+5;i>(y-5);i--)
		{
			YYYY += "<option value='"+i+"' >"+i+"</option>\r\n"
		}
		document.p.year.outerHTML=YYYY+"</select>"
		
		var MM=optionMonth.substring(0,optionMonth.length-9)
		for(var j=1;j<13;j++)
		{
			MM += "<option value='"+j+"'>"+j+"</option>\r\n"
		}
		document.p.month.outerHTML=MM+"</select>"
	
		document.p.year.value=y
		document.p.month.value=new Date().getMonth()+1
		
		var n=month[new Date().getMonth()]
		selectDay(n)
		document.p.day.value=new Date().getDate()
	}
	
	function isLeapYear(year)
	{
		if((year%4==0&&year%100!=0)||yaer%400==0)
			return true
	}
	
	function selectDay(n)
	{
		var DD=optionDay.substring(0,optionDay.length-9)
		for(var i=1;i<=n;i++)
		{
			DD += "<option value='"+i+"'>"+i+"</option>\r\n"
		}
		document.p.day.outerHTML=DD+"</select>"
	}
	
	function yearDay(yy)
	{
		var MMvalue = document.p.month.options[document.p.month.selectedIndex].value;
		if (MMvalue == "")
		{
			day.outerHTML = optionDay
			return
		}
		var n = month[MMvalue - 1];
		if (MMvalue ==2 && isLeapYear(yy))
			n++;
		selectDay(n)
	}
	
	function monthDay(mm)
	{
		var YYYYvalue = document.p.year.options[document.p.year.selectedIndex].value;
		if (mm== "")
		{
			day.outerHTML = optionDay
			return
		}
		var n = month[mm- 1];
		if (mm ==2 && isLeapYear(YYYYvalue)) 
			n++;
		selectDay(n)
	}
	</script>
	</head>
	<body>
		<form name="p" id="p" method="post">
			<select name="year" onChange="yearDay(this.value)">
				<option  value="" >Year</option>
			</select >
			<select name="month" onChange="monthDay(this.value)">
				<option  value="" >Month</option>
			</select>
			<select name="day">
				<option  value="">Day</option>
			</select>
		</form>
	</body>
</html>